<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('数据库连接修改')"/>
</head>
<body>
<form class="layui-form" action=""  th:object="${MonitorServer}">
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">

						<div class="layui-form-item layui-hide">
		                    <label class="layui-form-label">主键</label>
		                    <div class="layui-input-block">
		                        <input type="text" th:value="*{id}" name="id" lay-verify="title"
		                               autocomplete="off" class="layui-input">
		                    </div>
		                </div>
		
					
						<div class="layui-form-item">
		                    <label class="layui-form-label">主机</label>
		                    <div class="layui-input-block">
		                        <input th:value="*{host}" type="text" name="host" autocomplete="off" placeholder="主机地址" class="layui-input">
		                    </div>
		                </div>
					                
		
					
						<div class="layui-form-item">
		                    <label class="layui-form-label">端口</label>
		                    <div class="layui-input-block">
		                        <input th:value="*{port}" type="text" name="port" autocomplete="off" placeholder="端口" class="layui-input">
		                    </div>
		                </div>
					                
		
					
						<div class="layui-form-item">
		                    <label class="layui-form-label">用户名</label>
		                    <div class="layui-input-block">
		                        <input th:value="*{username}" type="text" name="username" autocomplete="off" placeholder="用户名" class="layui-input">
		                    </div>
		                </div>
					                
		
					
						<div class="layui-form-item">
		                    <label class="layui-form-label">密码</label>
		                    <div class="layui-input-block">
		                        <input th:value="*{password}" type="password" name="password" autocomplete="off" placeholder="密码" class="layui-input">
		                    </div>
		                </div>
					                
		
					
						<div class="layui-form-item">
		                    <label class="layui-form-label">版本</label>
		                    <div class="layui-input-block">
<!--		                        <input th:value="*{version}" type="text" name="version" autocomplete="off" placeholder="版本" class="layui-input">-->

								<select lay-verify="required" name="version" lay-filter="selectOnchange">
									<option th:selected="*{version} eq '8'" value="8">8</option>
									<option th:selected="*{version} eq '5.7'" value="5.7">5.7</option>
								</select>
							</div>
		                </div>
					                
		
					
						<div class="layui-form-item">
		                    <label class="layui-form-label">标签</label>
		                    <div class="layui-input-block">
		                        <input th:value="*{tags}" type="text" name="tags" autocomplete="off" placeholder="标签" class="layui-input">
		                    </div>
		                </div>
					                
		
					
						<div class="layui-form-item">
		                    <label class="layui-form-label">集群</label>
		                    <div class="layui-input-block">
<!--		                        <input th:value="*{clusterId}" type="text" name="clusterId" autocomplete="off" placeholder="集群" class="layui-input">-->

								<select lay-verify="required" name="clusterId" lay-filter="selectOnchange">
									<option
											th:each="item:${monitorClusterList}"
											th:value="${item.id}"
											th:text="${item.name}" th:selected="${item.id} eq ${clusterId}">
									</option>
								</select>

		                    </div>
		                </div>
					                
		
					
<!--						<div class="layui-form-item">-->
<!--		                    <label class="layui-form-label">创建时间</label>-->
<!--		                    <div class="layui-input-block">-->
<!--		                        <input th:value="*{createTime}" type="text" name="createTime" autocomplete="off" placeholder="创建时间" class="layui-input">-->
<!--		                    </div>-->
<!--		                </div>-->
<!--					                -->
<!--		-->
<!--					-->
<!--						<div class="layui-form-item">-->
<!--		                    <label class="layui-form-label">更新时间</label>-->
<!--		                    <div class="layui-input-block">-->
<!--		                        <input th:value="*{updateTime}" type="text" name="updateTime" autocomplete="off" placeholder="更新时间" class="layui-input">-->
<!--		                    </div>-->
<!--		                </div>-->
					                

            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit=""
                    lay-filter="monitorServer-update">
                <i class="layui-icon layui-icon-ok"></i>
				提交
            </button>
            <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
				重置
            </button>
        </div>
    </div>
</form>
<th:block th:include="include :: footer"/>
<script>
    layui.use(['form','laydate','jquery'], function () {
        let form = layui.form;
        let $ = layui.jquery;
        let MODULE_PATH = rootPath+"/MonitorServerController";


        form.on('submit(monitorServer-update)', function (data) {
        	let loader = layer.load();
            $.ajax({
                url: MODULE_PATH+'/edit',
                data: data.field,
                dataType: 'json',
                contentType: 'application/x-www-form-urlencoded',
                type: 'post',
                success: function (result) {
                    if (result.code==200) {
                        layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                            parent.layui.table.reload("monitorServer-table");
                            layer.close(loader);
                        });
                    } else {
                        layer.msg(result.msg, {icon: 2, time: 1000});
                        layer.close(loader);
                    }
                }
            })
            return false;
        });
    })
</script>
</body>
</html>